package com.seecen.controller;

import com.seecen.entity.Emp;
import com.seecen.service.EmpService;
import com.seecen.service.impl.EmpServiceImpl;
import com.seecen.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.lang.reflect.Field;

@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
//    @Qualifier("empServiceImpl") 有多个实现类对象时，使用@Qualifier指定具体实现类
    private EmpService empService;

    @PostMapping("/save")
    public Result<Emp> save(@RequestBody Emp emp) {
        try {
            empService.save(emp);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Result.success(emp);
    }
}
